Introduce a shared exact symbolic expression core - #1127
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1083. This is the first reviewable implementation layer of #1126.
Outcome
This PR replaces the duplicated symbolic-expression implementations with one canonical exact DAG and carries those exact expressions through reduction-path composition. Asymptotic
Growthis derived only when a terminal comparison or Big-O presentation needs it.Canonical expression core
problemreductions-expras the single parser and expression implementation used by the runtime library and proc macrosArc, preserving shared subexpressions through substitution and node-table serdeBigRationalconstants and validated owned symbolsConst,Var, n-aryAdd/Mul,Pow,Exp,Log, andFactorialExact path semantics
Growthin one shared analysis contextExplicit failure boundaries
0 / 0,0^-1, andlog(0)return parse errorsApproximationError; they never become successful infinities orO(1)GrowthFailurereasonsThere is no compatibility AST, parser fallback, antichain cap, or silent approximation fallback.
External oracle fixture
A committed fixture generated by pinned SymPy 1.14.0 checks:
Regenerate it with:
Stack boundary
This PR supplies the canonical expression core and integrates it with the existing overhead/path APIs. The named
SizeMap/SizeBoundtypes, complete registry field accounting, and separate exact-bound search APIs remain later stacked changes in #1126.Risk and rollback
This intentionally replaces the old expression representation rather than preserving compatibility. The main risk is semantic drift in normalization or path composition; the SymPy corpus, property tests, deep shared-DAG regressions, and full repository test suite cover those boundaries. Before later stack layers depend on this commit, rollback is a normal revert of this PR; no persisted schema migration is required.
Verification
make checkcargo test --workspace --quietAll passed.
Coverage